Sum of Distances in Tree problem